package com.lele.controller;

import com.lele.domain.User;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.security.Principal;

@Controller
public class RouterController {
    @RequestMapping("/main")
    public  String main(HttpServletRequest request, ModelMap modelMap){
        Principal userPrincipal = request.getUserPrincipal();
        if(userPrincipal != null){
            Authentication authentication = (Authentication) userPrincipal;

            User user = (User) authentication.getPrincipal();

            modelMap.put("user",user);
        }

        return "main";
    }
    @RequestMapping("/add")
    public String add() {
        return "add";
    }

    @RequestMapping("/del")
    public String del() {
        return "del";
    }

    @RequestMapping("/query")
    public String query() {
        return "query";
    }

    @RequestMapping("/update")
    public String update() {
        return "update";
    }

    @RequestMapping("/userLogin")
    public String userLogin() {
        return "login";
    }

    @RequestMapping("/checkLogin")
    public String checkLogin() {
        return "login";
    }

}
